package com.usefullc.demo.dao;

import com.usefullc.demo.domain.Demo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

/**
 * 示例DAO
 * @author: Sampson
 * @date: 2018-12-19 16:06
 */
public interface DemoDao extends JpaRepository<Demo, Long> {

    @Transactional
    @Modifying
    @Query(value = "update `demo` t set t.status = ?2,t.gmtModified=now(6) where t.id = ?1 and t.status != ?2",nativeQuery = true)
    int updateStatus(Long id, Integer status);


}
